﻿using HelpersDotNet.Extensions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Runtime.Serialization;

namespace HelpersDotNet.Test
{


    /// <summary>
    ///This is a test class for ExtensionsTest and is intended
    ///to contain all ExtensionsTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ExtensionsTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for IsValidEmailAddress
        ///</summary>
        [TestMethod()]
        public void IsValidEmailAddressTest()
        {
            string s = "a@a.com"; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = s.IsValidEmailAddress();
            Assert.AreEqual(expected, actual);

            s = "@a.com";
            actual = s.IsValidEmailAddress();
            Assert.AreNotEqual(expected, actual);

            s = "a@a.d";
            actual = s.IsValidEmailAddress();
            Assert.AreEqual(expected, actual,
                @"Should be valid for a@a.d invalid when .d is only one char it fails. fix it");
        }

        /// <summary>
        ///A test for IsEmpty
        ///</summary>
        [TestMethod()]
        public void IsEmptyTest()
        {
            Array array = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = array.IsNullOrEmpty();
            Assert.AreEqual(expected, actual);
        }


        /// <summary>
        ///A test for IsSerializable
        ///</summary>
        public void IsSerializableTestHelper<T>()
        {
            T obj = default(T); // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = Extensions_Accessor.IsSerializable<T>(obj);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        [DeploymentItem("Helpers.NET.dll")]
        public void IsSerializableTest()
        {
            bool expected = true;
            bool actual;

            SerializedClass s = new SerializedClass();
            NonSerializedClass ns = new NonSerializedClass();

            expected = true;
            actual = s.IsSerializable();
            Assert.AreEqual(expected, actual);

            actual = ns.IsSerializable();
            Assert.AreNotEqual(expected, actual);

        }
    }
}
